package zyz.framework.entity;

import java.io.Serializable;

public class NameValue implements Serializable {
	private static final long serialVersionUID = -6489843459647864242L;

	private String name;

	private Object value;

	private boolean isOr;

	private String condition;

	private String expression;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public boolean isOr() {
		return isOr;
	}

	public void setOr(boolean isOr) {
		this.isOr = isOr;
	}

	public String getCondition() {
		return condition == null ? "=" : condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public String getExpression() {
		return expression;
	}

	public void setExpression(String expression) {
		this.expression = expression;
	}

	/**
	 * 璁剧疆琛ㄨ揪寮忥紝鍙?鐢ㄤ簬Update鎿嶄綔
	 * @param name 鏁版嵁搴撳瓧娈靛悕
	 * @param expression 琛ㄨ揪寮忥紝濡俛ccount + 1
	 */
	public static NameValue setExpression(String name, String expression) {
		NameValue nameValue = new NameValue();
		nameValue.setName(name);
		nameValue.setExpression(expression);

		return nameValue;
	}

	public NameValue() {}

	/**
	 * @param name 鏁版嵁搴撳瓧娈靛悕
	 * @param value 鍊?
	 */
	public NameValue(String name, Object value) {
		this(name, value, null);
	}

	/**
	 * @param name 鏁版嵁搴撳瓧娈靛悕
	 * @param value 鍊?
	 * @param condition 鏉′欢(=,>,<,in,not in绛?
	 */
	public NameValue(String name, Object value, String condition) {
		this.name = name;
		this.value = value;
		this.condition = condition;
	}

	/**
	 * @param name 鏁版嵁搴撳瓧娈靛悕
	 * @param value 鍊?
	 * @param condition 鏉′欢(=,>,<,in,not in绛?
	 * @param isOr true:or/false:and
	 */
	public NameValue(String name, Object value, String condition, boolean isOr) {
		this.isOr = isOr;
		this.name = name;
		this.value = value;
		this.condition = condition;
	}
}